<template>
    <div class="madp-product-manage">
        <basic-container>
            <div class="header">
                <el-form :inline="true">
                    <el-form-item label="活动名称:">
                        <el-input v-model.trim="searchT" maxlength="20" placeholder="请输入活动名称"></el-input>
                    </el-form-item>
                    <el-form-item><el-button @click="handleSearch" type="primary">搜索</el-button> </el-form-item>
                </el-form>
            </div>
            <table-node ref="table1" :searchT="searchT" :tableType="1" @handleView="handleView" />
            <table-node ref="table2" :searchT="searchT" @handleView="handleView" @handleUpdate="handleUpdate" />
        </basic-container>
        <dialog-node :dialogTitle="dialogTitle" :showDialog="showDialog" :dialogInfo="dialogInfo" @handleClose="showDialog = false" :onlyRead="onlyRead" />
    </div>
</template>
<script>
import tableNode from './table.vue';
import dialogNode from './dialog.vue';
export default {
    components: {
        tableNode,
        dialogNode
    },
    data() {
        return {
            // 搜索框内容
            searchT: '',
            // 弹窗标题
            dialogTitle: '',
            // 弹窗开关
            showDialog: false,
            // 弹窗内容
            dialogInfo: {},
            // 是否只读
            onlyRead: true,
            // 时间限制
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7;
                }
            }
        };
    },
    methods: {
        // 点击搜索
        handleSearch() {
            this.$refs.table1.getList();
            this.$refs.table2.getList();
        },
        // 刷新
        handleUpdate() {
            this.$refs.table1.getList(1);
            this.$refs.table2.getList(1);
            this.showDialog = false;
        },
        // 点击查看
        handleView(data) {
            this.dialogInfo = data;
            this.dialogTitle = '查看活动';
            this.showDialog = true;
        }
    }
};
</script>
<style scoped lang="scss">
.header {
    display: flex;
    justify-content: space-between;
}
</style>
